package cn.linjianhui.api.client.invoker;

import cn.linjianhui.api.client.DataFormat;

public abstract class RPCInvoker {
    protected String serviceUri;
    protected String baseAddress;
    protected String[] parameters;
    protected Class<?> returnType;  // 返回类型
    protected Class<?> genericType; // 泛型类型
    protected ClientAuthenticator authenticator;
    protected Serializer serializer;
    protected DataFormat dataFormat;

    public RPCInvoker(String serviceUri, String baseAddress, String[] parameters, Class<?> returnType,
                      Class<?> genericType, ClientAuthenticator authenticator, Serializer serializer, DataFormat dataFormat) {
        this.serviceUri = serviceUri;
        this.baseAddress = baseAddress;
        this.parameters = parameters;
        this.returnType = returnType;
        this.genericType = genericType;
        this.authenticator = authenticator;
        this.serializer = serializer;
        this.dataFormat = dataFormat;
    }

    abstract public Object doMethodInvoker(Object[] methodArgs) throws Exception;

    public void setSerializer(Serializer serializer) {
        this.serializer = serializer;
    }
}
